/**
 * @author Mario Meir-Huber
 */

package com.cloudvane.ossc;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class CloudStorageClient {
	
	private ICloudStorageProxy proxy;

	/**
	 * Instantiates cloud storage client
	 */
	public CloudStorageClient() {
		 
	}
	
	/**
	 * Instantiates cloud storage client
	 * @param s
	 * @throws IOException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws ClassNotFoundException
	 */
	public CloudStorageClient(InputStream s) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
		Properties props = new Properties();         
		props.load(s);
		
		setClient(props.getProperty("Provider"));
	}
	
	/**
	 * Creates the client
	 * @param clientName
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws ClassNotFoundException
	 */
	public void setClient(String clientName) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		String client = "com.cloudvane.ossc." + clientName;
		proxy = (ICloudStorageProxy)Class.forName(client).newInstance();
		
		System.out.println(proxy.getStorageClient());
	}
	
	/**
	 * Gets the storage client
	 * @return
	 */
	public ICloudStorageProxy getClient() {
		return this.proxy;
	}
}
